<?php

namespace app\client\controller\learn;

use app\common\controller\Frontend;
use app\common\enums\AccountTypeEnum;
use app\common\model\banxi\learn\LearnSayVocabularyRecord as LearnSayVocabularyRecordModel;
use app\common\service\learn\LearnSayVocabularyService;

class LearnSayVocabularyRecord extends Frontend
{
    protected array $noNeedLogin = [];

    protected array $noNeedPermission = ['*'];

    public function initialize(): void
    {
        parent::initialize();
    }


    //测试列表
    public function listVocabularyData()
    {
        $param = $this->request->param(['index', 'limit', 'orderBy', "query"]);
        $studentId = $this->auth->id;
        $param['query']['EQ_studentId'] = $studentId;
        $param['query']['EQ_isSubmit'] = 1;
        //查询条件解析
        $where = get_query($param);
        //获取分页数据
        $pageParams = get_page_params($param);
        $LearnSayVocabularyRecordModel = new LearnSayVocabularyRecordModel();
        $list = $LearnSayVocabularyRecordModel->getVocabularyList($where, $pageParams['page'], $pageParams['limit']);
        $this->ok('ok', result_row($list));

    }

    //获取报告
    public function getVocabularyRecord()
    {
        $vocabularyRecordId = $this->request->get('vocabularyRecordId');
        if (!$vocabularyRecordId) {
            $this->fail('请选择测试记录');
        }
        $LearnSayVocabularyService = new LearnSayVocabularyService();
        $info = $LearnSayVocabularyService->getVocabularyRecord($vocabularyRecordId);
        $this->ok('ok', $info);
    }
}